package com.qst.dao;

import com.qst.pojo.Meeting;
import com.qst.pojo.MeetingParticipants;
import com.qst.pojo.SearchMeeting;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Eumenides.
 * @create 2021-06-21 21:12
 */
@Repository
public interface MeetingDao {

    /**
     * 查询所有会议
     *
     * @return java.util.List<com.qst.pojo.Meeting>
     * @Param []
     * @author Eumenides
     */
    List<SearchMeeting> findAllMeeting(@Param("searchMeeting") SearchMeeting meeting);

    List<Meeting> findMeetingById(Integer rId);


    /**
     * 查询已取消会议
     *
     * @param reservationistid
     * @return
     */
    List<Meeting> findCancelMeeting(Integer reservationistid);

    /**
     * 取消会议
     *
     * @param meetingid
     */
    @Update("update meetings SET status = 1 where meetingid = #{meetingid}")
    void cancelMeeting(Integer meetingid);

    /**
     * 删除会议
     *
     * @param meetingid
     */
    @Delete("delete from meetings where meetingid = #{meetingid}")
    void delMeeting1(Integer meetingid);

    @Delete("delete from meetingparticipants where meetingid = #{meetingid}")
    void delMeeting(Integer meetingid);

    /**
     * 还原会议
     *
     * @param meetingid
     */
    @Update("update meetings SET status = 0 where meetingid = #{meetingid}")
    void reMeeting(Integer meetingid);

    List<Meeting> findmeeting(Integer reservationistid);

    @Select("select * from meetings where roomid=#{meetingRoomId}")
    List<Meeting> findMeetingByMeetingRoom(int meetingRoomId);

    @Insert("insert into meetingparticipants(meetingid,employeeid) values(#{meetingid},#{employeeid})")
    Integer saveMeetingPeople(MeetingParticipants meetingParticipants);

    Integer saveMeeting(Meeting meeting);


    /**
     * 查询当前会议
     *
     * @param roomid
     * @return
     */
    Meeting findThisMeeting(Meeting meeting);

    @Select("select employeename from employee where employeeid = #{employeeid}")
    String findOrderPerson(Integer employeeid);

    /**
     * 根据meetingid和employeeid删除该参会人员
     *
     * @param meetingid
     * @param employeeid
     */
    @Delete("delete from meetingparticipants where meetingid = #{meetingid} and employeeid = #{employeeid}")
    void delMeetingEmployeeByMeetingId(@Param("meetingid") Integer meetingid, @Param("employeeid") Integer employeeid);
}
